package com.imyours.webservice.services;

import org.hibernate.Session;

import com.imyours.model.user.UserEntity;
import com.imyours.model.util.HibernateUtil;
import com.imyours.webservice.service.Context;
import com.imyours.webservice.service.ContextService;
import com.imyours.webservice.services.annotation.Service;


@Service(name="friendInfo")
public class FriendInfo extends ContextService {

	public FriendInfo(Context context) {
		super(context);
	}

	public void execute() {
		UserEntity user = getUserEntity();
		if(user!=null){
			long uid = Long.parseLong(context.getParameter().get("user"));
			Session se = HibernateUtil.getSessionFactory().openSession();
			UserEntity ue = (UserEntity) se.get(UserEntity.class, uid);
			if(ue!=null){
				context.putResult("nickName", ue.getNickname());
				context.success();
			}
		}
				
		
	}

}
